package cn.chinaflame.pagodas.repository;

import cn.chinaflame.pagodas.entity.PaProductArea;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface PaProductAreaRepository extends JpaRepository<PaProductArea, String> {

    @Query("select c from PaProductArea c where c.name like ?1 and c.state=0")
    public List<PaProductArea> findByName(String name);

    @Query("select c from PaProductArea c where c.name like ?1 and c.state=0")
    public Page<PaProductArea> findByName(String name, Pageable p);
    
    @Query("select substring(c.areaNo,1,2) from PaProductArea c where c.state = 0")
	public List<String> loadProductAreas() ;
    
}
